package com.netease.nim.uikit.business.session.emoji;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.netease.nim.uikit.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 翻译的适配器
 */
public class TranslateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context context;

    private int startIndex;

    private List<String> dataList = new ArrayList<>();

    public void setDataList(List<String> dataList){
        this.dataList = dataList;
        notifyDataSetChanged();
    }

    public TranslateAdapter(Context mContext, int startIndex) {
        this.context = mContext;
        this.startIndex = startIndex;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new TransHolder(LayoutInflater.from(context).inflate(R.layout.item_translate_list, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ((TransHolder)holder).lag_item.setText(dataList.get(position));
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    class TransHolder extends RecyclerView.ViewHolder {

        TextView lag_item;

        TransHolder(View itemView) {
            super(itemView);
            lag_item = itemView.findViewById(R.id.lag_item);
        }
    }

}